package Demo2;

//内部类

class OuterClass{
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;
    class InnerClass{
        public int data1 = 111;
        public int data4 = 4;
        public static final int data5 = 5;
        private int data6 = 6;

        public void Innertest(){
            System.out.println("内部类");
            System.out.println(data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }
    public void Test(){
        System.out.println("外部类");
    }
}

class Out{
    public int a = 1;
    public static int b =2;
    private int c = 3;

    static class In{
        public int ia = 1;
        public int ib = 2;
        public int ic = 3;
        public void Intest(){
            System.out.println("静态内部类");
        }
    }
}

interface IA{
    void test();
}

public class Test {
    public static void main(String[] args) {

        IA ia = new IA() {
            @Override
            public void test() {
                System.out.println("重写了接口的方法");
            }
        };
        ia.test();

        new IA() {
            @Override
            public void test() {
                System.out.println("重写了接口的方法");
            }
        }.test();
    }
    public static void main2(String[] args) {
        Out.In in = new Out.In();
        System.out.println(in.ia);
        in.Intest();
    }

    public static void main1(String[] args) {
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass= outerClass.new InnerClass();
        innerClass.Innertest();
        System.out.println(OuterClass.InnerClass.data5);
//        OuterClass.InnerClass innerClass = new OuterClass.InnerClass();

    }
}
